Compiling Exceptions Correctly

نویسنده

  • Tobias Nipkow
چکیده

An exception compilation scheme that dynamically creates and removes exception handler entries on the stack. A formalization of an article of the same name by Hutton and Wright [1]. 1 Compiling exception handling theory Exceptions imports Main begin 1.1 The source language datatype expr = Val int | Add expr expr | Throw | Catch expr expr consts eval :: "expr ⇒ int option" primrec "eval (Val i) = Some i" "eval (Add x y) = (case eval x of None ⇒ None | Some i ⇒ (case eval y of None ⇒ None | Some j ⇒ Some(i+j)))" "eval Throw = None" "eval (Catch x h) = (case eval x of None ⇒ eval h | Some i ⇒ Some i)" 1.2 The target language datatype instr = Push int | ADD | THROW | Mark nat | Unmark | Label nat | Jump nat datatype item = VAL int | HAN nat types code = "instr list" stack = "item list" consts exec2 :: "bool * code * stack ⇒ stack"

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Compiling Exceptions Correctly

Exceptions are an important feature of modern programming languages, but their compilation has traditionally been viewed as an advanced topic. In this article we show that the basic method of compiling exceptions using stack unwinding can be explained and verified both simply and precisely, using elementary functional programming techniques. In particular, we develop a compiler for a small lang...

متن کامل

Compiling Exceptions Correctly (Extended Version)

Exceptions are an important feature of modern programming languages, but their compilation has traditionally been viewed as an advanced topic. In this article we show that the basic method of compiling exceptions using stack unwinding can be explained and verified both simply and precisely, using elementary functional programming techniques. In particular, we develop a compiler for a small lang...

متن کامل

Compiling and reasoning about exceptions and interrupts

Exceptions and interrupts are important for programming reliable software systems, yet our methods for reasoning about them are weak. In this thesis we explore the problem of compiling and reasoning about exceptions and interrupts in the context of a simple language. We develop the language in three stages, initially without any form of exceptions, then adding exceptions, and finally adding int...

متن کامل

Compiling Natural Semantics Into ML

This paper presents a compilation scheme from natural semantics speciications to ML. Permutations of premises allow, for a class of speciications, a purely functional execution and can reduce non-determinism. This method uses some speciic features of ML, like exceptions , closures and pattern-matching.

متن کامل

Towards a Cost-Effective Estimation of Uncaught Exceptions in SML Programs

We present a static analysis that detects potential runtime exceptions that are raised and never handled inside Standard ML (SML) programs. This analysis will predict abrupt termination of SML programs , which is SML's only one \safety hole." Even though SML program's control ow and exception ow are in general mutually dependent, analyzing the two ows are safely decoupled. Program's control-ow ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Archive of Formal Proofs

دوره 2004  شماره 

صفحات  -

تاریخ انتشار 2004